import 'package:flutter/material.dart';
import 'package:get/get.dart';

// 封装的新组件
class notData extends StatelessWidget {
  final String text; // 自定义文字
  final IconData icon; // 自定义图标
  final VoidCallback? onTap; // 点击事件回调

  const notData({
    Key? key,
    this.text = "暂无数据",
    this.icon = Icons.warning,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center( // 确保内容在屏幕居中
      child: GestureDetector(
        onTap: onTap, // 绑定点击事件
        child: Container(
          padding: const EdgeInsets.all(24),
          decoration: BoxDecoration(
          //  color: Colors.white,
            borderRadius: BorderRadius.circular(16),
           /* boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(0.2),
                spreadRadius: 5,
                blurRadius: 7,
                offset: const Offset(0, 3), // changes position of shadow
              ),
            ],*/
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              AnimatedContainer(
                duration: const Duration(milliseconds: 300),
                curve: Curves.easeInOut,
                child: Icon(
                  icon,
                  size: 64,
                  color: Colors.grey[600],
                ),
              ),
              const SizedBox(height: 20),
              Text(
                text.tr,
                style: TextStyle(
                  fontSize: 18,
                  color: Colors.grey[600],
                  fontWeight: FontWeight.w500,
                ),
                textAlign: TextAlign.center,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
